package it.creazionicreative;

import it.creazionicreative.engine.EngineManager;
import it.creazionicreative.engine.GPSEngine;
import it.creazionicreative.engine.TTSEngine;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SquidAIActivity extends Activity {

	private EngineManager enginemanager;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    
        
        setContentView(R.layout.main);
        
        Button bt = (Button) findViewById(R.id.button1);
        bt.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				  setContentView(R.layout.mainpanel);
			}
		});
        init();
    }
	
	private void init()
	{
		enginemanager = new EngineManager();
		enginemanager.addEngine(new TTSEngine(this));
		enginemanager.addEngine(new GPSEngine(this));
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
		{
			Log.i(getLocalClassName(), "OK TTS Installed");
		
			((TTSEngine)enginemanager.getEngine(Const.ENGINE_TTS)).InitTTS();						
		}
		else
		{
			((TTSEngine)enginemanager.getEngine(Const.ENGINE_TTS)).InitDownloadTTSData();	
		}

		super.onActivityResult(requestCode, resultCode, data);
	}
}